{% extends "layout.html" %}
{% block title %}登录{% endblock %}
{% block head %}
{% endblock %}
{% block main_content %}
<div id="body">
  <div class="wrap">
    <div class="primary">
      <div class="sect">
        <h2>登录</h2>
        <div class="sectContent">
          <form action="/login/" method="post" onsubmit="if(!login(this)) return false;">
            <div class="gForm">
              <div class="row">
                <label>注册邮箱：</label>
                <input name="username" type="text" class="inputbox shortinput" id="username" />
              </div>
              <div class="row">
                <label>密码：</label>
                <input type="password" class="inputbox shortinput" id="pass" />
                <input name="password" type="hidden" id="password" />
                <a href="/user/reset_pass/">忘记密码了？</a> 
              </div>
              <div class="sectBtn">
                <input type="submit" name="button" id="button" class="buttonLarge" value="登录" />
                	还没有账号？&nbsp;<a href="/reg/">马上去注册</a>
                <p id="err_txt" class="alert">{{ errors.get('login', '') }}</p>
              </div>
              <input type="hidden" name="to" 
              	value="{%if request.args.has_key('to')%}{{ request.args.get('to','') }}{%elif _redirect_url%}{{_redirect_url}}{%else%}/{%endif%}" />
            </div>
          </form>
        </div>
      </div>
    </div>
    <div class="secondary secSpec">
      <div class="sect">
        <h2>登录...</h2>
        <div class="sectContent">
          <div class="textBox">
            <p>欢迎登录！欢迎给我们指出问题，提出建议！</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
{% endblock %}
{% block popup_content %}
<script type="text/javascript">
function checkIn(){
	var name = $("username").value; var pass = $("pass").value;
	var err = $("err_txt");
	if(!$chk2(name)){ err.innerHTML = "请输入注册邮箱"; return false; }
	if(!$chk2(pass)){ err.innerHTML = "请输入密码"; return false; }
	return true;
}
function login(obj){
	if(checkIn()){
		$("password").value = MD5($("pass").value);
		obj.submit();
	}
}
var un = Cookie.read("un");
if(un) { $("username").value = un; $("pass").focus();}
else{ $("username").focus(); }
</script>
{% endblock %}